package cc.rengu.redp.bizimpl.upmp.controller;

import cc.rengu.redp.bizimpl.upmp.common.BusinessContainer;
import cc.rengu.redp.bizimpl.upmp.domain.*;
import cc.rengu.redp.bizimpl.upmp.service.*;
import cc.rengu.redp.bizimpl.upmp.vo.MerchantLevelInfo;
import cc.rengu.redp.bizimpl.upmp.vo.OperationResult;
import cc.rengu.redp.bizimpl.upmp.vo.UpmpUserInfoVO;
import cc.rengu.redp.bizimpl.utils.Common;
import cc.rengu.redp.bizimpl.utils.CommonUtils;
import cc.rengu.redp.bizimpl.utils.ExtPropertyPlaceholderConfigurer;
import cc.rengu.redp.bizimpl.utils.RedpUpmpUtil;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * -makeby lizk
 * 商户等级限额管理
 */
@RestController
@Slf4j
@RequestMapping("/admin/quota/merchantGradeManager")
public class MerchantGradeQuotaManagetController extends BaseController {
    @Resource
    private ResourceLoader resourceLoader;
    @Autowired
    private IUpmpSysParamService upmpSysParamService;
    @Autowired
    private BTxnLimitCfgService bTxnLimitCfgService;
    @Autowired(required = false)
    private ExtPropertyPlaceholderConfigurer extPropertyPlaceholderConfigurer;
    @Autowired
    private MerchantGradeQuotaManagetService merchantGradeQuotaManagetService;
    @Autowired
    private IUpmpBMchntBaseInfoService bMchntBaseInfoService;
    @Autowired
    private IUpmpBMchntLevelInfoService mchntLevelInfoService;

    @Autowired
    private IUpmpOrganizationService iUpmpOrganizationService;
    @GetMapping
    public Map<String, Object> findByPage(QueryRequest request, BTxnLimitCfg entity) {
        return getDataTable(this.merchantGradeQuotaManagetService.findByPage(request, entity));
    }


//    @RequiresPermissions("商户限额管理:商户级限额管理")
    @GetMapping("mchntLevel")
    public OperationResult mchntLevel(String instId,String mchntNo) {
        String MchntNoLevel = "";
//        String mchntNo = request.getParameter("mchntNo");
//        String instId = request.getParameter("instId");
        String mchntLevelName="";
        try {
            UpmpBMchntBaseInfo bymchntno = bMchntBaseInfoService.findByMchntNo(mchntNo);
            if(Common.isBlank(bymchntno)){
                return OperationResult.buildFailureResult("获取商户信息失败");
            }
            UpmpBMchntLevelInfo mchntlevelinfo = mchntLevelInfoService.findOneByCode(bymchntno.getMchntLevel(), "01", instId);
            if (Common.isBlank(mchntlevelinfo)) {
                return OperationResult.buildFailureResult("获取商户等级失败");
            }
            mchntLevelName=mchntlevelinfo.getMchntLevelName();//获取商户名称
            MchntNoLevel=mchntlevelinfo.getMchntLevelCode();//获取商户等级R
        } catch (Exception e) {
            log.error("获取商户等级时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("获取商户等级时系统异常");
        }
        return OperationResult.buildSuccessResult(mchntLevelName,MchntNoLevel);
    }

    /**
     * 获取未配置限额的商户等级List
     */
    @GetMapping("/getAddMerLevelInfos")
    public OperationResult getAddMerLevelInfos(@RequestParam("instId") String instId) {
        List<MerchantLevelInfo> merLevel = null;
        try {
            merLevel = merchantGradeQuotaManagetService.getAddMerLevelInfos(instId);
        } catch (Exception e) {
            log.error("获取商户等级信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("获取商户等级信息时系统异常");
        }

        return OperationResult.buildSuccessResult(merLevel);
    }



    /**
     * 新增商户等级限额配置
     */
    @PostMapping("saveMerGradeQuota")
    public OperationResult saveMerGradeQuota(BTxnLimitCfg txnLimitCfg) {

        try {
            verfiyData(txnLimitCfg);
            merchantGradeQuotaManagetService.saveMerGradeQuota(txnLimitCfg);
        }catch (RedpException e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:"+e.getMessage());

        }  catch (Exception e) {
            log.error("保存限额信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:请联系管理员");

        }
        return OperationResult.buildSuccessResult();
    }

    /**
     * 修改商户等级信息
     */
//    @RequiresPermissions("商户限额管理:商户等级限额管理")
    @PutMapping("editMerGradeQuota")
    public OperationResult editMerGradeQuota(BTxnLimitCfg txnLimitCfg) {

        try {
            verfiyData(txnLimitCfg);
            merchantGradeQuotaManagetService.editMerGradeQuota(txnLimitCfg);
        } catch (RedpException e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:"+e.getMessage());

        } catch (Exception e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:请联系管理员");

        }
        return OperationResult.buildSuccessResult();
    }



    /**
     * 启用商户等级限额配置
     */

//    @RequiresPermissions("商户限额管理:商户等级限额管理")
    @PutMapping(value = "startMcGradeQuota")
    public OperationResult startMcGradeQuota(BTxnLimitCfg req) {

        try {
            merchantGradeQuotaManagetService.startMcGradeQuota(req);
        } catch (RedpException e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:"+e.getMessage());

        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:请联系管理员");        }
        return OperationResult.buildSuccessResult();
    }

    /**
     * 停用商户等级限额配置
     */
//    @RequiresPermissions("商户限额管理:商户等级限额管理")
    @PutMapping("stopMcGradeQuota")
    public OperationResult stopMcGradeQuota(BTxnLimitCfg req) {

        try {
            merchantGradeQuotaManagetService.stopMcGradeQuota(req);
        }catch (RedpException e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:"+e.getMessage());

        }  catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:请联系管理员");        }
        return OperationResult.buildSuccessResult();
    }

    /**
     * 注销商户等级限额配置
     */
//    @RequiresPermissions("商户限额管理:商户等级限额管理")
    @PutMapping("deleteMcGradeQuota")
    public OperationResult deleteMcGradeQuota(BTxnLimitCfg req) {

        try {
            merchantGradeQuotaManagetService.deleteMcGradeQuota(req);
        } catch (RedpException e) {
            log.error("保存限额信息操作时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额信息操作时系统异常:"+e.getMessage());

        } catch (Exception e) {
            log.error("保存限额操作信息时系统异常:[{}]", e);
            return OperationResult.buildFailureResult("保存限额操作信息时系统异常:请联系管理员");
        }
        return OperationResult.buildSuccessResult();
    }



    private void verfiyData(BTxnLimitCfg txnLimitCfgVo) throws RedpException {
        String mchntLevelCode = txnLimitCfgVo.getMchntLevelCode();
        String dayLimitAmt = txnLimitCfgVo.getDayLimitAmt();
        String monthLimitAmt = txnLimitCfgVo.getMonthLimitAmt();
        String dayLimitLoanAmt = txnLimitCfgVo.getDayLimitLoanAmt();
        String monthLimitLoanAmt = txnLimitCfgVo.getMonthLimitLoanAmt();
        String singleLimitLoanMaxAmt = txnLimitCfgVo.getSingleLimitLoanMaxAmt();
        String dayLimitCreditAmt = txnLimitCfgVo.getDayLimitCreditAmt();
        String monthLimitCreditAmt = txnLimitCfgVo.getMonthLimitCreditAmt();
        String singleLimitCreditMaxAmt = txnLimitCfgVo.getSingleLimitCreditMaxAmt();
        if(StringUtils.isBlank(mchntLevelCode)){
            throw new RedpException("商户等级编号不能为空");
        }

        if(StringUtils.isNotBlank(dayLimitAmt)&&StringUtils.isNotBlank(monthLimitAmt)){
            if(Double.parseDouble(dayLimitAmt)>Double.parseDouble(monthLimitAmt)){
                throw  new RedpException("日累计限额不能大于月累计限额");
            }
        }
        //------日累计限额

        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("日累计借记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("单笔借记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("日累计贷记限额不能大于日累计限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(dayLimitAmt)) {
                throw new RedpException("单笔贷记限额不能大于日累计限额");
            }
        }
        //-----月累计限额
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(monthLimitLoanAmt)) {
            if (Double.parseDouble(monthLimitLoanAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("月累计借记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("日累计借记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("单笔借记限额不能大于月累计限额");
            }
        }


        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(monthLimitCreditAmt)) {
            if (Double.parseDouble(monthLimitCreditAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("月累计贷记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("日累计贷记限额不能大于月累计限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(monthLimitAmt)) {
                throw new RedpException("单笔贷记限额不能大于月累计限额");
            }
        }

        //-------借记
        if (StringUtils.isNotBlank(monthLimitLoanAmt) && StringUtils.isNotBlank(dayLimitLoanAmt)) {
            if (Double.parseDouble(dayLimitLoanAmt) > Double.parseDouble(monthLimitLoanAmt)) {
                throw new RedpException("日累计借记限额不能大于月累计借记限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitLoanAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(monthLimitLoanAmt)) {
                throw new RedpException("单笔借记限额不能大于月累计借记限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitLoanAmt) && StringUtils.isNotBlank(singleLimitLoanMaxAmt)) {
            if (Double.parseDouble(singleLimitLoanMaxAmt) > Double.parseDouble(dayLimitLoanAmt)) {
                throw new RedpException("单笔借记限额不能大于日累计借记限额");
            }
        }
        //-------贷记
        if (StringUtils.isNotBlank(monthLimitCreditAmt) && StringUtils.isNotBlank(dayLimitCreditAmt)) {
            if (Double.parseDouble(dayLimitCreditAmt) > Double.parseDouble(monthLimitCreditAmt)) {
                throw new RedpException("日累计贷记限额不能大于月累计贷记限额");
            }
        }
        if (StringUtils.isNotBlank(monthLimitCreditAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(monthLimitCreditAmt)) {
                throw new RedpException("单笔贷记限额不能大于月累计贷记限额");
            }
        }
        if (StringUtils.isNotBlank(dayLimitCreditAmt) && StringUtils.isNotBlank(singleLimitCreditMaxAmt)) {
            if (Double.parseDouble(singleLimitCreditMaxAmt) > Double.parseDouble(dayLimitCreditAmt)) {
                throw new RedpException("单笔贷记限额不能大于日累计贷记限额");
            }
        }
    }


    /**
     * 生成 Excel导入模板
     *
     * @param response
     */
    @PostMapping("getExcel")
    public void generateImportTemplate(HttpServletResponse response) {
        InputStream inputStream = null;
        ServletOutputStream servletOutputStream = null;
        try {
            String filename = "mchntLevelQuotaImportTemplate.xlsx";
            String path = "template/mchntLevelQuotaImportTemplate.xlsx";
            org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:" + path);

            response.setContentType("application/vnd.ms-excel");
            response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
            response.addHeader("charset", "utf-8");
            response.addHeader("Pragma", "no-cache");
            String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
            response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);

            inputStream = resource.getInputStream();
            servletOutputStream = response.getOutputStream();
            IOUtils.copy(inputStream, servletOutputStream);
            response.flushBuffer();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (servletOutputStream != null) {
                    servletOutputStream.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
                // jvm的垃圾回收
                System.gc();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


    /**
     * 导入Excel数据
     *
     * @param excelFile
     * @return
     * @throws Exception
     */

//    @RequiresPermissions("商户限额管理:商户等级限额管理")
    @RequiresPermissions("merchantGradeManager:import")
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    @ResponseBody
    public OperationResult getDataFromExcel(@RequestParam("file") MultipartFile excelFile, @RequestParam("instId") String InstId) throws Exception {

        try {
            String originalFilename = excelFile.getOriginalFilename();
            if (!originalFilename.endsWith(".xls") && !originalFilename.endsWith(".xlsx")) {
                log.error("文件不是excel类型");
                return OperationResult.buildFailureResult("文件不是excel类型");
            }

            UpmpUserInfoVO user = RedpUpmpUtil.getCurrentUser(InstId);
           // List<UpmpSysParam> childrenByPrimaryKey = upmpSysParamService.findChildrenByPrimaryKey("MCHNT_IMPORT_PARAM", InstId, user.getId());
            UpmpSysParam dataDict = upmpSysParamService.findChildrenByPrimaryKeyAndParent("MCHNT_IMPORT_PARAM", BusinessContainer.SYS_IMPORT_EXPORT_PARAM, InstId, null);
            if(Common.isBlank(dataDict)){
                log.error("解析文件时获取系统参数失败，请联系系统管理员");
                throw new RedpException("解析文件时获取系统参数失败，请联系系统管理员");
            }
            if(Common.isBlank(dataDict.getRichtextValue())){
                log.error("解析文件时获取系统参数值失败，请联系系统管理员");
                throw new RedpException("解析文件时获取系统参数值失败，请联系系统管理员");
            }
            Map sysparam = (Map) JSON.parse(dataDict.getRichtextValue());
          int maxRecords = Common.isBlank(sysparam.get("MAX_RECORDS"))?Integer.valueOf(extPropertyPlaceholderConfigurer.getProperty("MCHNT_IMPORT_MAX_RECORDS")):Integer.valueOf(sysparam.get("MAX_RECORDS").toString());
            ArrayList<BTxnLimitCfg> bankLevelQuotaList = new ArrayList<>();
            Workbook workbook =null;
            if(originalFilename.endsWith(".xlsx")){
                workbook=new XSSFWorkbook(excelFile.getInputStream());
            }else if(originalFilename.endsWith(".xls")){
                workbook=new HSSFWorkbook(excelFile.getInputStream());
            }

            Sheet sheetAt = workbook.getSheetAt(0);
            int lastRowNum = sheetAt.getLastRowNum();
            if(maxRecords<lastRowNum){
                log.error("导入文件中限额信息记录数超过{}！",maxRecords);
                throw new RedpException("导入文件中限额信息记录数超过"+maxRecords+"！");
            }
            if(lastRowNum>0){
                //校验模板是否正确
                verifyTable(sheetAt.getRow(0));

                String instId1 = "";
                String crtOrgId = "";
                if(user.isAdmin()){
                    UpmpOrganization headOrg = iUpmpOrganizationService.getHeadOrgByCode(instId1);
                    crtOrgId = headOrg == null ? user.getOrgCode() : headOrg.getOrgCode();
                    instId1=InstId;
                }else{
                    instId1 = user.getInstId();
                    crtOrgId = user.getOrgCode();
                }
                List<MerchantLevelInfo> addMerLevelInfos = merchantGradeQuotaManagetService.getAddMerLevelInfos(instId1);
                if(null == addMerLevelInfos || addMerLevelInfos.size() < 1){
                    throw new RedpException("不存在未配置限额信息的商户等级！");
                }

                for (int i = 1; i <= lastRowNum; i++) {
                    BTxnLimitCfg bankLevelQuota = new BTxnLimitCfg();
                    Row rowTitle = sheetAt.getRow(i);
                    if (rowTitle != null) {// 行不为空
                        // 读取cell
                        bankLevelQuota.setMchntLevelCode(CommonUtils.getValue(rowTitle.getCell(0)));
                        bankLevelQuota.setDayLimitAmt(CommonUtils.getValue(rowTitle.getCell(1)));
                        bankLevelQuota.setMonthLimitAmt(CommonUtils.getValue(rowTitle.getCell(2)));
                        bankLevelQuota.setSingleLimitLoanMaxAmt(CommonUtils.getValue(rowTitle.getCell(3)));
                        bankLevelQuota.setDayLimitLoanAmt(CommonUtils.getValue(rowTitle.getCell(4)));
                        bankLevelQuota.setMonthLimitLoanAmt(CommonUtils.getValue(rowTitle.getCell(5)));
                        bankLevelQuota.setSingleLimitCreditMaxAmt(CommonUtils.getValue(rowTitle.getCell(6)));
                        bankLevelQuota.setDayLimitCreditAmt(CommonUtils.getValue(rowTitle.getCell(7)));
                        bankLevelQuota.setMonthLimitCreditAmt(CommonUtils.getValue(rowTitle.getCell(8)));
                        bankLevelQuota.setInstId(instId1);
                        bankLevelQuota.setCrtOrgId(crtOrgId);
                        if (StringUtils.isBlank(bankLevelQuota.getMchntLevelCode())) {
                            throw new RedpException("数据非空校验不通过");
                        }
                        verfiyData(bankLevelQuota);
                        verfiyMchntLevel(bankLevelQuota.getMchntLevelCode(),addMerLevelInfos);
                        bankLevelQuotaList.add(bankLevelQuota);
                    }
                }
                merchantGradeQuotaManagetService.batchUploadBankQuotal(bankLevelQuotaList,instId1);
            }else{
                return OperationResult.buildFailureResult("文件为空，没有可导入的数据");
            }
        }catch (Exception e) {
            log.error("数据导入失败:[{}]", e);
            return OperationResult.buildFailureResult("数据导入失败:系统异常"+e.getMessage());
        }
        return OperationResult.buildSuccessResult("数据导入成功");
    }


    private void verfiyMchntLevel(String mchntLevelCode,List<MerchantLevelInfo> addMerLevelInfos) throws RedpException {
        for(MerchantLevelInfo merchantLevelInfo: addMerLevelInfos){
            if(mchntLevelCode.equals(merchantLevelInfo.getMchntLevelCode())){
                return;
            }
        }
        throw new RedpException("该商户等级信息不存在或限额配置信息已添加:"+mchntLevelCode);
    }
    private void verifyTable(Row row) throws RedpException {
        if(!("商户等级编号".equals(CommonUtils.getValue(row.getCell(0))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("日累计限额".equals(CommonUtils.getValue(row.getCell(1))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("月累计限额".equals(CommonUtils.getValue(row.getCell(2))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("单笔借记限额".equals(CommonUtils.getValue(row.getCell(3))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("日累计借记限额".equals(CommonUtils.getValue(row.getCell(4))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("月累计借记限额".equals(CommonUtils.getValue(row.getCell(5))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("单笔贷记限额".equals(CommonUtils.getValue(row.getCell(6))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("日累计贷记限额".equals(CommonUtils.getValue(row.getCell(7))))){
            throw new RedpException("导入模板不匹配");
        }
        if(!("月累计贷记限额".equals(CommonUtils.getValue(row.getCell(8))))){
            throw new RedpException("导入模板不匹配");
        }
    }
}